#include "gtkseparatormenuitem.h"
#include "gtkmenu.h"
#include "gtkimage.h"
+#include "gtklabel.h"
#include "gtkobject.h"
#include "gtktooltips.h"
#include "gtktypebuiltins.h"
/* size of the icons of the menu items */
gint icon_size;
+ /* max size of the menu item label */
+ gint label_width;
+
/* RecentChooser properties */
gint limit;
guint show_private : 1;
#define FALLBACK_ICON_SIZE 32
#define FALLBACK_ITEM_LIMIT 10
+#define DEFAULT_LABEL_WIDTH 30
#define GTK_RECENT_CHOOSER_MENU_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_RECENT_CHOOSER_MENU, GtkRecentChooserMenuPrivate))
priv->icon_size = FALLBACK_ICON_SIZE;
+ priv->label_width = DEFAULT_LABEL_WIDTH;
+
priv->current_filter = NULL;
priv->tooltips = gtk_tooltips_new ();
gint count)
{
GtkRecentChooserMenuPrivate *priv;
- gchar *label;
- GtkWidget *item, *image;
+ gchar *text;
+ GtkWidget *item, *image, *label;
GdkPixbuf *icon;
g_assert (info != NULL);
/* avoid clashing mnemonics */
if (count <= 10)
- label = g_strdup_printf ("_%d. %s", count, escaped);
+ text = g_strdup_printf ("_%d. %s", count, escaped);
else
- label = g_strdup_printf ("%d. %s", count, escaped);
+ text = g_strdup_printf ("%d. %s", count, escaped);
- item = gtk_image_menu_item_new_with_mnemonic (label);
+ item = gtk_image_menu_item_new_with_mnemonic (text);
g_free (escaped);
g_free (name);
}
else
{
- label = g_strdup (gtk_recent_info_get_display_name (info));
- item = gtk_image_menu_item_new_with_label (label);
+ text = g_strdup (gtk_recent_info_get_display_name (info));
+ item = gtk_image_menu_item_new_with_label (text);
+ }
+
+ g_free (text);
+
+ /* ellipsize the menu item label, in case the recent document
+ * display name is huge.
+ */
+ label = GTK_BIN (item)->child;
+ if (label)
+ {
+ gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
+ gtk_label_set_max_width_chars (GTK_LABEL (label), priv->label_width);
}
if (priv->show_icons)
G_CALLBACK (item_activate_cb),
menu);
- g_free (label);
-
return item;
}